﻿using System;
using System.Collections.Generic;

using System.Text;
using ITAP.Core.Modelling.Primitives;
using ITAP.ShprossesBuilder.Modelling;
using ITAP.ShprossesBuilder.Calculations;
using ITAP.Core.Modelling;
using ITAP.Core.Calculations;

namespace ITAP.ShprossesBuilder.Info
{
    public class SpacerMachineInfo
    {
        private List<SpacerElementInfo> spacerElementsInfo;

        public List<SpacerElementInfo> SpacerElementsInfo
        {
            get { return spacerElementsInfo; }
        }

        public SpacerMachineInfo(List<IEndedPrimitive> spacerPrimitives)
        {
            // TODO Проверить формирование информации по выгрузке на гнутьевую
            spacerElementsInfo = new List<SpacerElementInfo>();
            Angle currentAngle;
            IEndedPrimitive firstPrimitive = spacerPrimitives[0];
            for (int i = 0; i < spacerPrimitives.Count; i++)
            {
                if (i == spacerPrimitives.Count - 1)
                    currentAngle = ModelCalculations.GetAngleBetweenVectors(firstPrimitive.GetTangent(0), spacerPrimitives[i].GetTangent(1).Rotate(new Angle(Math.PI)), false);
                else
                    currentAngle = ModelCalculations.GetAngleBetweenVectors(spacerPrimitives[i + 1].GetTangent(0), spacerPrimitives[i].GetTangent(1).Rotate(new Angle(Math.PI)), false);
                spacerElementsInfo.Add(new SpacerElementInfo(spacerPrimitives[i], currentAngle));
            }
        }
    }

    public class SpacerElementInfo
    {
        private IEndedPrimitive primitive;

        public IEndedPrimitive Primitive
        {
            get { return primitive; }
        }
        private Angle angleBetweenNextPrimitive;

        public Angle AngleBetweenNextPrimitive
        {
            get { return angleBetweenNextPrimitive; }
        }

        public SpacerElementInfo(IEndedPrimitive primitive, Angle angleBetweenNextPrimitive)
        {
            this.primitive = primitive;
            this.angleBetweenNextPrimitive = angleBetweenNextPrimitive;
        }

    }
}
